FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

GPU_PATCHES = "file://weston.ini \
            file://desktop.png \
            file://weston-start \ 
"

SRC_URI_append = " ${@bb.utils.contains('MACHINE_FEATURES', 'gpu', '${GPU_PATCHES}', '', d)}"

SRC_URI_append_mx8dx = "${@bb.utils.contains('MACHINE_FEATURES', 'wayland', ' file://weston.config', '', d)}"

# To customize weston.ini, start by setting the desired assignment in weston.ini,
# commented out. For example:
#     #xwayland=true
# Then add the assignment to INI_UNCOMMENT_ASSIGNMENTS.
INI_UNCOMMENT_ASSIGNMENTS_append_mx8mp = " \
    use-g2d=1 \
"

do_install_append() {
    if ${@bb.utils.contains('MACHINE_FEATURES','gpu','true','false',d)}; then
        install -Dm0755 ${WORKDIR}/desktop.png ${D}${sysconfdir}/xdg/weston/
        install -D -p -m0644  ${WORKDIR}/weston.ini  ${D}${sysconfdir}/xdg/weston/weston.ini
        install -Dm755 ${WORKDIR}/weston-start ${D}${bindir}/weston-start
        sed -i 's,@DATADIR@,${datadir},g' ${D}${bindir}/weston-start
        sed -i 's,@LOCALSTATEDIR@,${localstatedir},g' ${D}${bindir}/weston-start
    fi
}

SYSTEMD_AUTO_ENABLE = "enable"
